package com.eascs.ticket.configuration.controller;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.eascs.common.util.UrlUtil;
import com.eascs.site.page.PaginationInfo;
import com.eascs.site.page.SelectDataOption;
import com.eascs.site.view.ViewContext;
import com.eascs.site.view.button.AjaxButton;
import com.eascs.site.view.button.Button;
import com.eascs.ticket.common.controller.BaseMasterViewController;
import com.eascs.ticket.configuration.form.WorkdayListForm;
import com.eascs.ticket.configuration.service.WorkdayService;

@Controller
public class WorkdayViewController extends BaseMasterViewController {
	@Inject
	private WorkdayService workdayService;

	@RequestMapping(value = "/workday/list")
	public String list(WorkdayListForm workdayListForm) {
		PaginationInfo paginationInfo = new PaginationInfo(this.workdayService.getWorkdays(workdayListForm.getPageIndex()), new String[] { "日期", "是否工作日" });
		paginationInfo.setSelectDataOptions(new SelectDataOption[] { null, new SelectDataOption("yes_no") });
		paginationInfo.setUrl(UrlUtil.resetParam(com.eascs.web.context.RequestContext.getRequestUrlWithQueryString(), "pageIndex", ""));
		Button button = new AjaxButton("修改是否为工作日", "/workday/getUpdateWorkdayView?id=");
		button.setPermissionCode("admin");
		paginationInfo.setMoreButtons(new Button[] { button });
		ViewContext.put("paginationInfo", paginationInfo);
		return "/view/paginationInfo";
	}

}
